<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%@ include file="/sys/include/header.jsp" %>
<HTML>
 <HEAD>
  <TITLE> 添加城市信息 </TITLE>
	<link href="sys/style01/css/table.css" rel="stylesheet" type="text/css" />
	<link href="sys/css/banzu.css" rel="stylesheet" type="text/css"  >
<%   
  //设置缓存为空   
  response.setHeader("Pragma","No-cache");   
  response.setHeader("Cache-Control","no-cache");   
  response.setDateHeader("Expires",   0);   
  %>

<script type="text/javascript">

function save()
{			
		if(document.queryFrom.queryCityCode.value==""){
			alert("请输入城市的编码!");
			return;
		}
		if(document.queryFrom.queryCityName.value==""){
			alert("请输入城市的名称!");
			return;
		}

		if(document.queryFrom.queryCityLevel.value==""){
			alert("请输入城市的级别!");
			return;
		}

		if(document.queryFrom.emp_province_code.value==""){
			alert("请选择省份!");
			return;
		}
		document.queryFrom.submit();
}	

var xmlhttpPop;
var areaNowPop;
function selectAreaPop(areaCode,areaValue,area){
	areaNowPop = area;
	var url = "";
				 
	xmlhttpPop=createXmlPop();
	if (xmlhttpPop==null) {
    	alert ("您的浏览器不支持AJAX！");
    	return;
    }
   
    if(areaNowPop=='emp_area')
  		url="hr/ajaxGetAreaList.action?queryAreaCode="+areaCode+"&sid="+Math.random();
  	if(areaNowPop=='emp_province')
  		url="hr/ajaxGetCityList.action?queryAreaCode="+areaCode+"&sid="+Math.random();

  	if(url!=""){
	  xmlhttpPop.onreadystatechange=areaChangedPop;
	  xmlhttpPop.open("GET",url,true);
	  xmlhttpPop.send(null);
  }
}

function createXmlPop(){
	var xmlhttpd;
	try{
		xmlhttpd= new ActiveXObject('msxml2.xmlhttp');
	}catch(e){
		try{
			xmlhttpd=new ActiveXObject('Microsoft.xmlhttp');
		}catch(e){
		 	try{
		 		xmlhttpd=new XMLHttpRequest();
			}catch(e){}
		}
	}
	return xmlhttpd;
}

//区域选择，ajax返回
function areaChangedPop(){
	var provinceCodePop = new Array();
	var provinceValuePop = new Array();
 	if (xmlhttpPop.readyState == 4&&xmlhttpPop.status == 200){
 	var xmlDoc = xmlhttpPop.responseXML.documentElement;
 	//var str=xmlhttpPop.responseText;
 	if (xmlDoc == null) {
		return;
	}
	var flagYn = true;
	var until = xmlDoc.childNodes;
	for (var idx=0; idx < until.length; idx++) {
		var peer = xmlDoc.childNodes[idx];
		if(areaNowPop=='emp_area'&&peer.tagName=='province'){
			provinceCodePop[provinceCodePop.length] = peer.text.split(",")[0];
		 	provinceValuePop[provinceValuePop.length] = peer.text.split(",")[1];
		 	continue;
		 }
		 
		 if(areaNowPop=='emp_province'&&peer.tagName=='city'){
			provinceCodePop[provinceCodePop.length] = peer.text.split(",")[0];
		 	provinceValuePop[provinceValuePop.length] = peer.text.split(",")[1];
		 	continue;
		 }
	}			 

	
	if(areaNowPop=='emp_area'){
		if(provinceCodePop.length>0){
			document.queryFrom.emp_province_code.innerHTML="";
			document.queryFrom.emp_province_code.options[0]=new Option("请选择","");
			for(var i=0;i<provinceCodePop.length;i++)
				document.queryFrom.emp_province_code.options[i+1]=new Option(provinceValuePop[i],provinceCodePop[i]);
			document.queryFrom.emp_province_code.selectedIndex  = 0;
		}else{
			document.queryFrom.emp_province_code.innerHTML="";
			document.queryFrom.emp_province_code.options[0]=new Option("请选择","");
		}
		if(document.queryFrom.emp_city_code){
				document.queryFrom.emp_city_code.innerHTML="";
				document.queryFrom.emp_city_code.options[0]=new Option("请选择","");
			}
	}
	if(areaNowPop=='emp_province'){
		if(provinceCodePop.length>0){
			document.queryFrom.emp_city_code.innerHTML="";
			document.queryFrom.emp_city_code.options[0]=new Option("请选择","");
			for(var i=0;i<provinceCodePop.length;i++)
				document.queryFrom.emp_city_code.options[i+1]=new Option(provinceValuePop[i],provinceCodePop[i]);
			document.queryFrom.emp_city_code.selectedIndex  = 0;
		}else{
			document.queryFrom.emp_city_code.innerHTML="";
			document.queryFrom.emp_city_code.options[0]=new Option("请选择","");
		}
	}
	areaNowPop = "";
	}
}
</script>

 </HEAD>

 <BODY class="ridgeBody"> 

<form name="queryFrom" method="post" action="business/city/cityInsertDo.action">

  <table class=datatable width=50% cellpadding='0' cellspacing='0' border='1' bordercolorDark='white' bordercolorLight='#BEBEBE' >
      <!--DWLayoutTable-->
      <tr >
        <TD height="28" colspan="2" valign="top" class="dataTitle">添加城市信息</TD>
    </tr>
    <tr>
		<td height="26" with="25%" nowrap="nowrap" class="datatr1"><span class="STYLE1" ><font color="#FF0000">*</font></span>区域：</td>
		<td height="26" with="25%">
			<select class="selectwidth" name="emp_area_code" onChange="selectAreaPop(this.options[selectedIndex].value,this.options[selectedIndex].text,'emp_area')"  >
				<option value="" selected>请选择</option>
				<c:forEach items="${areaList}" var="area">
					<option value="${area.areaCode}" <c:if test="${area.areaCode==emp_area_code}">selected</c:if>>${area.areaValue}</option>	
				</c:forEach>
			</select>
		</td>
	</tr>
	<tr>
		<td height="26" with="25%" nowrap="nowrap" class="datatr1"><span class="STYLE1"><font color="#FF0000">*</font></span>省份：</td>
		<td height="26" with="25%">
			<select class="selectwidth" name="emp_province_code">
				<option value="" selected>请选择</option>
				<c:forEach items="${provinceList}" var="province">
					<option value="${province.provinceCode}" <c:if test="${province.provinceCode==emp_province_code}">selected</c:if>>${province.provinceName}</option>	
				</c:forEach>
			</select>
		</td>
	</tr>
	 <tr>
        <TD height="22" valign="top" nowrap class="datatr1"><font color="#FF0000">*</font> 城市编码：</TD>	
	<TD valign="top" nowrap > 
	      <input name="queryCityCode" type="text" class="input" /> 	</TD>
 	 </tr>
      <tr>
        <TD height="22" valign="top" nowrap class="datatr1"> <font color="#FF0000">*</font>城市级别：</TD>	
	<TD valign="top" nowrap > 
	      <input name="queryCityLevel" type="text" class="input" /> 	</TD>
 	 </tr>
      <tr>
        <TD height="22" valign="top" nowrap class="datatr1"> <font color="#FF0000">*</font>城市名称：</TD>	
	<TD valign="top" nowrap > 
	      <input name="queryCityName" type="text" class="input" /> 	</TD>
 	 </tr>
 	 <tr>
 	 <td height="26" with="25%" nowrap="nowrap" class="datatr1"><span class="STYLE1"></span>城市群：</td> 
 	 <td height="26" with="25%">
			<select class="selectwidth" name="citys_code"  >
				<option value="" selected>请选择</option>
				<c:forEach items="${cityslist}" var="citys">
					<option value="${citys.citysCode}" <c:if test="${citys.citysCode==citys_code}">selected</c:if>>${citys.citysValue}</option>	
				</c:forEach>
			</select>
		</td>
 	 </tr>
      
      <tr >
        <TD height="21" colspan="2" class="dataTitle">  <input type="button" name="Submit1" value="提交" onClick="save()"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	      <input type="reset" name="Input" value="重置" /></TD>
	</tr>
	  <%	
        if(request.getAttribute("message")!=null)
        {
        	String message=request.getAttribute("message").toString();
        %>
     	 
     	 <tr>
     	   <td height="2" colspan="4" valign="top"><%=message%></td>

   	   </tr>
     	 
     	 
  		 <%}%>
    </table>
  
</form>

 </BODY>
</HTML>